================================================================================
CHECKLIST GENERATE VOUCHER AGENT - PASTIKAN SEMUA ✓
================================================================================

PERSIAPAN SISTEM:
=================

□ File lib/routeros_api.class.php ada
  → Berisi fungsi randNULC(), randLC(), dll
  → Lokasi: mikhmon/lib/routeros_api.class.php

□ File agent/generate.php sudah diupdate
  → Include routeros_api.class.php
  → Koneksi MikroTik seperti admin
  → Generate dengan randNULC()

□ Database agent_system sudah ada
  → Tabel: agent_system
  → Tabel: agent_vouchers
  → Tabel: agent_transactions
  → Tabel: agent_prices

□ MikroTik sudah dikonfigurasi
  → IP, username, password benar
  → Hotspot sudah aktif
  → Profile sudah dibuat

PERSIAPAN DATA:
===============

□ Admin sudah dibuat
  → Username: admin
  → Password: (sesuai config)
  → Bisa login ke MikhMon

□ Agent sudah dibuat
  → Nama, username, password sudah diset
  → Status: Active
  → Agent code: AG001 (contoh)

□ Saldo agent sudah ada
  → Minimal Rp 10.000 untuk testing
  → Bisa topup dari admin panel

□ Harga profile sudah diset
  → Buka: Agent Management → Kelola Harga Agent
  → Set harga beli dan harga jual
  → Contoh: 1Jam → Beli: 2000, Jual: 3000

SEBELUM TESTING:
================

□ Admin HARUS login dulu
  → Buka: http://localhost/mikhmon/admin.php
  → Login dengan username/password admin
  → Koneksi ke MikroTik berhasil
  → JANGAN logout!

□ Cek session MikroTik aktif
  → Session tersimpan di include/config.php
  → Berisi data koneksi MikroTik
  → Agent akan menggunakan session ini

□ Browser sudah clear cache
  → Ctrl + Shift + Delete
  → Clear cache dan cookies
  → Restart browser

TESTING GENERATE:
=================

□ Login sebagai agent
  → URL: http://localhost/mikhmon/agent/
  → Username: (username agent)
  → Password: (password agent)

□ Buka halaman Generate Voucher
  → Klik menu "Generate Voucher"
  → Halaman terbuka tanpa error
  → Saldo tersedia muncul di atas

□ Isi form generate
  → Pilih profile: (pilih yang sudah ada harganya)
  → Jumlah voucher: 1 (untuk testing)
  → Nomor WhatsApp: (opsional)
  → Nama customer: (opsional)

□ Klik "Generate Voucher Sekarang"
  → Tunggu proses (2-5 detik)
  → Perhatikan hasilnya

HASIL YANG DIHARAPKAN:
======================

□ Muncul alert hijau
  → "✅ Berhasil generate 1 voucher!"

□ Muncul card voucher
  → Username: AG2aB3cD5e (contoh)
  → Password: 5xY7zC (contoh)
  → Profile: (sesuai pilihan)

□ Saldo berkurang
  → Saldo lama - harga beli = saldo baru
  → Contoh: 10.000 - 2.000 = 8.000

□ Voucher bisa di-copy
  → Klik tombol "Copy"
  → Paste di notepad
  → Username dan password ter-copy

□ Voucher bisa di-print
  → Klik tombol "Print Voucher"
  → Tampilan print OK
  → Bisa print ke PDF

VERIFIKASI HASIL:
=================

□ Cek di MikroTik
  → Login ke MikroTik Winbox
  → IP → Hotspot → Users
  → Cari username: AG... (yang baru di-generate)
  → Profile dan comment sesuai

□ Cek di database
  → Buka phpMyAdmin
  → Database: mikhmon
  → Tabel: agent_vouchers
  → Cari voucher yang baru di-generate
  → Data lengkap (username, password, profile, dll)

□ Cek transaksi agent
  → Buka menu "Transaksi" di agent panel
  → Cari transaksi generate voucher
  → Tanggal, profile, harga sesuai

□ Cek saldo agent
  → Refresh dashboard
  → Saldo berkurang sesuai harga beli
  → Saldo tersisa = saldo lama - total biaya

TESTING LANJUTAN:
=================

□ Generate multiple voucher
  → Quantity: 5
  → Semua voucher ter-generate
  → Saldo terpotong 5x harga beli

□ Generate dengan profile berbeda
  → Profile 1Jam: berhasil
  → Profile 1Hari: berhasil
  → Profile 1Minggu: berhasil

□ Test WhatsApp integration
  → Centang "Kirim via WhatsApp"
  → Masukkan nomor valid
  → WhatsApp terkirim

□ Test print voucher
  → Klik "Print Voucher"
  → Tampilan print OK
  → Print ke PDF berhasil

□ Test copy semua voucher
  → Klik "Copy Semua"
  → Paste di notepad
  → Semua voucher ter-copy

TROUBLESHOOTING:
================

Jika ada error, cek:

□ Error: "Session MikroTik tidak ditemukan"
  → Admin belum login
  → Login dulu sebagai admin
  → Koneksi ke MikroTik
  → Coba lagi

□ Error: "Harga untuk profile ini belum diset"
  → Buka admin panel
  → Kelola Harga Agent
  → Set harga untuk profile
  → Coba lagi

□ Error: "Saldo tidak mencukupi"
  → Topup saldo agent
  → Minimal = harga beli × quantity
  → Coba lagi

□ Error: "Gagal terhubung ke MikroTik"
  → Cek koneksi internet
  → Cek MikroTik online
  → Cek IP, username, password
  → Login ulang sebagai admin

□ Error: "Call to undefined function randNULC()"
  → File routeros_api.class.php tidak di-include
  → Cek file agent/generate.php
  → Pastikan ada: include('../lib/routeros_api.class.php');
  → Refresh halaman

□ Voucher tidak muncul di MikroTik
  → Cek koneksi MikroTik
  → Cek profile ada di MikroTik
  → Cek user limit di MikroTik
  → Cek log MikroTik

MONITORING:
===========

□ Dashboard agent
  → Saldo tersedia
  → Total voucher
  → Total profit

□ Menu Transaksi
  → History generate voucher
  → Tanggal, profile, harga
  → Filter by date

□ Menu Voucher Saya
  → Semua voucher yang pernah di-generate
  → Filter by profile, status
  → Search by username

□ Menu Kelola Harga
  → Harga beli dan harga jual
  → Profit per voucher
  → Update harga

DOKUMENTASI:
============

□ Baca GENERATE_FIXED_FINAL.txt
  → Penjelasan lengkap perbaikan

□ Baca TESTING_GENERATE_AGENT.txt
  → Panduan testing step by step

□ Baca PERBANDINGAN_KODE.txt
  → Perbandingan cara lama vs baru

□ Baca FUNGSI_HELPER_REFERENCE.txt
  → Referensi fungsi randNULC(), dll

□ Baca RINGKASAN_PERBAIKAN.txt
  → Ringkasan perbaikan

FINAL CHECK:
============

□ Generate 1 voucher: BERHASIL ✓
□ Voucher muncul di MikroTik: BERHASIL ✓
□ Saldo terpotong dengan benar: BERHASIL ✓
□ Data tersimpan di database: BERHASIL ✓
□ Generate multiple voucher: BERHASIL ✓
□ WhatsApp terkirim: BERHASIL ✓
□ Print voucher: BERHASIL ✓
□ Copy voucher: BERHASIL ✓

JIKA SEMUA ✓ → GENERATE VOUCHER AGENT BERHASIL! 🎉

================================================================================
CATATAN PENTING:
================================================================================

1. Admin HARUS login dulu sebelum agent generate
   → Session MikroTik dari admin akan digunakan oleh agent

2. Harga profile HARUS diset dulu
   → Buka admin panel → Kelola Harga Agent

3. Saldo agent HARUS cukup
   → Minimal = harga beli × quantity

4. Fungsi randNULC() HARUS tersedia
   → Include routeros_api.class.php

5. Koneksi MikroTik HARUS OK
   → Cek IP, username, password

6. Database HARUS sudah ada
   → Jalankan agent_system.sql

7. Profile HARUS ada di MikroTik
   → Buat di MikroTik Hotspot User Profile

8. JANGAN logout admin saat agent generate
   → Session MikroTik akan hilang

================================================================================
SELAMAT MENCOBA! 🎉
================================================================================
